package com.ruoyi.system.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.tree.ITree;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.data.annotation.Transient;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;


/**
 * 省、市、区
 * 
 * @author zscat
 * @email 163@qq.com
 * @date 2021-07-19 14:20:59
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
@ToString
@TableName("t_provinces")
public class Provinces implements ITree<Provinces>, Serializable {

	//编码
	@TableId(type = IdType.ASSIGN_ID)
	private Integer cityCode;
	//名称
	private String name;
	//父id
	private Integer parentId;
	//简称
	private String shortName;
	//级别
	private Integer depth;
	//
	private String zipCode;
	//
	private String mergerName;
	//经度
	private String longitude;
	//纬度
	private String latitude;
	//拼音
	private String pinyin;

	@TableField(exist = false)
	@Transient
	private List<Provinces> children = new ArrayList<>();

	@Override
	public String id() {
		return String.valueOf(cityCode);
	}

	@Override
	public String ancestors() {
		return null;
	}

	@Override
	public Integer type() {
		return null;
	}

	@Override
	public String label() {
		return name;
	}

	@Override
	public String parentId() {
		return String.valueOf(parentId);
	}

	@Override
	public void parentId(String parentId) {
		this.parentId = Integer.parseInt(parentId);
	}

	@Override
	public List<Provinces> getChildren() {
		return children;
	}

	@Override
	public void childrenToEmpty() {
		children = new ArrayList<>();
	}
}
